#define _CRT_SECURE_NO_WARNINGS
#include<iostream>


//https://www.luogu.com.cn/problem/P1161
using namespace std;

const int N = 2e6+10;
bool l[N];
int  t, n;
double a;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a >> t;
		for (int j = 1; j <= t; ++j)
		{
			int index = int(a * j);
			l[index] = !l[index];
		}
	}


	for (int i = 1; i <= N; ++i)
	{
		if (l[i]) { cout << i << endl; break; }
	}

	return 0;
}